home *** CD-ROM | disk | FTP | other *** search
- /* strrchr.c From TC Bible page 296 Use strrchr to find the last occurrence
- of a particular character in a given string */
-
- #include <stdio.h>
- #include <string.h>
- main()
- {
- char buf[80], *result;
- printf("Enter date: ");
- gets(buf);
- if ((result = strrchr(buf, '/')) == NULL)
- {
- printf("%s <-- not a date!\n", buf);
- }
- else
- {
- result++; /* Skip the '/' */
- printf("The year is: 19%s\n", result);
- }
- }